<template>
  <div class="mt-96">
    <div class="release-main ">
      <div class="rele-list mb-20">
        <ul>
          <li class="m-padding curent">
            <span>游戏帐号</span>
            <input maxlength="25" class="rele-input-tx2" name="" v-model="gameAccount"
                   placeholder="请输入游戏帐号">
          </li>
          <li class="m-padding ">
            <span>游戏密码</span>
            <input maxlength="25" class="rele-input-tx2" name="" v-model="gamePassword"
                   placeholder="请输入游戏密码">
          </li>

          <li class="m-padding ">
            <span>游戏角色名</span>
            <input maxlength="25" class="rele-input-tx2" name="" v-model="roleName" placeholder="请输入游戏角色名">
          </li>

        </ul>

      </div>
      <!--<div class="rele-list dl-pubish mb-20" id="bully-deposit" v-if="deposit">-->
        <!--<ul>-->
          <!--<li class="m-padding curent">-->
            <!--<span>我要求打手缴纳</span>-->
            <!--<input maxlength="6" class="rele-input-tx" name="" type="tel" v-model="prices"-->
                   <!--placeholder="请输入金额" ref="dPrice">-->
            <!--<em>元押金</em>-->
          <!--</li>-->
        <!--</ul>-->
      <!--</div>-->

      <div class="inds-foot">
        <div class="rele-btn">
          <a class="active" @click="next">确定</a>
        </div>
      </div>
    </div>
    <process :isTo="isTo"></process>
  </div>
</template>

<script>
  import Process from '../common/Process.vue'
  export default {
    name: '',
    data () {
      return {
        gameAccount: '',
        gamePassword: '',
        roleName: '',
//        prices: '',
        postData: {},
        deposit: true,
        isTo:2
      }
    },
    components: {
      Process
    },
//    watch: {
//      prices(Val, oldVal){
//        if (Val) {
//          this.prices = Val.toString().replace(/[^\d.]/g, "").//只允许一个小数点
//          replace(/^\./g, "").replace(/\.{2,}/g, ".").//只能输入小数点后两位
//          replace(".", "$#$").replace(/\./g, "").replace("$#$", ".").replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3')
//        }
//      }
//    },
    mounted(){
      this.$bus.emit('headerText', '提供帐号信息给打手');
      this.$bus.emit('proText', '代练流程');
      this.$bus.emit('isDl', true)
      this.getLevelingInfo();
    },
    destroyed(){
      this.$bus.emit('headerText', '');
      this.$bus.emit('isDl', false)
      this.$bus.emit('proText', '');
    },
    methods: {
      getLevelingInfo(){
        var self = this;
        self.$http.post(self.$CONSTANTS.APIdl + 'leveling/getLevelingInfo', {releaseNum: self.$route.query.releaseNum}).then((res) => {
          if (res.body.levelingEO != "") {
            self.gameAccount = res.body.levelingEO.gameAccount;
            self.roleName = res.body.levelingEO.roleName;
            self.prices = res.body.levelingEO.bullyDeposit;
            if (res.body.levelingEO.playerSafePlay != null && res.body.levelingEO.playerSafePlay != undefined) {
              self.deposit = false;
            }
          }
        }, (res) => {
          console.log(res)
        });
      },
      next(){
        var self = this;
        if (self.gameAccount == "") {
          this.$messagebox.alert('请输入游戏账号');
          return false
        }
        if (self.gamePassword == "") {
          this.$messagebox.alert('请输入游戏密码');
          return false
        }
        if (self.roleName == "") {
          this.$messagebox.alert('请输入游戏角色名');
          return false
        }
        if (self.prices == "") {
          this.$messagebox.alert('押金不能为空');
          return false
        }
        if (self.prices >= 99999) {
          this.$messagebox.alert('押金数目过大');
        }
        self.postData.gameAccount = self.gameAccount;
        self.postData.gamePassword = self.gamePassword;
        self.postData.releaseNum = self.$route.query.releaseNum;
        self.postData.roleName = self.roleName;
        self.$http.post(self.$CONSTANTS.APIdl + 'leveling/providePlayerInfo', self.postData).then((res) => {
          if(res.body.responseStatus.code == "00"){
            self.$router.push({
              name:'DlSeller',params:{state:'publish'}
            })
          }
        }, (res) => {
          console.log(res)
        });
      }
    }
  }
</script>

<style src="css/dlAll/dl-cxy.css"></style>
<style scoped>
  li.m-padding.curent {
    display: block;
    height: 1.1rem;
    line-height: 1.1rem;
    font-size: .32rem;
    width: 100%;
    float: none;
  }

  .rele-list ul li .rele-input-tx {
    width: 3.1rem;
    height: 1.08rem;
    padding: .25rem 0 !important;
    font-size: .32rem;
    float: left;
    line-height: 1.08rem !important;
  }
</style>
